package com.ynsj.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ynsj.mapper.AdminBankMapper;
import com.ynsj.domain.AdminBank;
import com.ynsj.service.AdminBankService;
import org.springframework.util.StringUtils;

@Service
public class AdminBankServiceImpl extends ServiceImpl<AdminBankMapper, AdminBank> implements AdminBankService{

    /**
     * 分页查询银行卡信息
     *
     * @param page
     * @param bankCard
     * @return
     */
    @Override
    public Page<AdminBank> findByPage(Page<AdminBank> page, String bankCard) {
        return page(page,new LambdaQueryWrapper<AdminBank>().like(!StringUtils.isEmpty(bankCard),AdminBank::getBankCard,bankCard));
    }

    /**
     * 启用/禁用银行卡信息
     *
     * @param bankId
     * @param status
     * @return
     */
    @Override
    public boolean updateStatus(Long bankId, Integer status) {
        return update(new LambdaUpdateWrapper<AdminBank>()
                .eq(bankId!=null,AdminBank::getId,bankId)
                .set(status!=null,AdminBank::getStatus,status));
    }
}
